function macTimeUtility(){
	this.y=0;
	this.m=0;
	this.d=0;
	this.h=0;
	this.m=0;
	this.s=0;
}

macTimeUtility.prototype.isSwitch=function(year){
	if(((year%4)==0) && (((year%100)!=0) || ((year%400)==0))) return true; else return false;
}

macTimeUtility.prototype.secPerYear=function(year){
	if(this.isSwitch(year)) return 31622400; else return 31536000;
}

macTimeUtility.prototype.secPerMonth=function(month,year){
	dpm=new Array( 31,0,31,30,31,30,31,31,30,31,30,31);
	days=dpm[month];
	if(month==1 && this.isSwitch(year)) days=29; else days=28;
	secs=days*24*3600;
	return secs;
}

macTimeUtility.prototype.fromInteger=function(macsecs){
	if(macsecs>0){
		remsecs=macsecs;
		fullyears=1904;
		fullmonths=1;
		spy=this.secPerYear(fullyears);
		while(remsecs>spy){ remsecs-=spy; spy=this.secPerYear(++fullyears); }
		this.yy=fullyears;

		spm=this.secPerMonth(fullmonths,fullyears);
		while(remsecs>spm){ remsecs-=spm; spm=this.secPerMonth(++fullmonths); }
		this.mm=fullmonths;

		fulldays=Math.floor(remsecs/86400)+1;
		remsecs%=86400;
		this.dd=fulldays;
		
		fullhours=Math.floor(remsecs/3600);
		remsecs%=3600;
		this.h=fullhours;		

		fullmin=Math.floor(remsecs/60);
		remsecs%=60;
		this.m=fullmin;		
		
		this.s=remsecs;	
	}else{
		this.yy=0;this.mm=0;this.dd=0; this.h=0; this.m=0; this.s=0;
	}
}

macTimeUtility.prototype.toString=function(secs){
	if(secs!=undefined) this.fromInteger(secs);
	
	if(this.yy>0)
		return this.yy+"-"+this.mm+"-"+this.dd+" "+this.h+":"+this.m+":"+this.s;
	else
		return "Unspecified";
	
}
